#pragma once
#include <QImage>
#include <QMap>
#include <QString>
struct ImageInfo
{
	int		w;
	int		h;
	bool	isSelected;
	QString text;
};
inline bool operator<(const ImageInfo& e1, const ImageInfo& e2)
{
	return (e1.w < e2.w) || (e1.h < e2.h) || (e1.isSelected < e2.isSelected) || (e1.text < e2.text);
}
QImage gen(int width, int height, bool isSelected, const QString& text);
class ImageManager
{
public:
	static ImageManager* getInstance();

	virtual ~ImageManager();
	QImage genTextImage(int width, int height, bool isSelected, const QString& text);
	QImage genTextImageWithCache(int width, int height, bool isSelected, const QString& text);

	void clearCache();

private:
	ImageManager();

private:
	QMap<ImageInfo, QImage> mImageCacheMap;
	QString					mLastString;
};

#define gImageMgr ImageManager::getInstance()
